#ifndef RATECONTROLLER_H
#define RATECONTROLLER_H

#include <QObject>
#include <QSet>
#include <QTime>

class NNTPWireClient;

class RateController : public QObject
{
Q_OBJECT
public:
    //explicit RateController(QObject *parent = 0);
    static RateController *instance();

    void addSocket(NNTPWireClient *socket);
    void removeSocket(NNTPWireClient *socket);

    inline int uploadLimit() const { return upLimit; }
    inline int downloadLimit() const { return downLimit; }
    inline void setUploadLimit(int bytesPerSecond) { upLimit = bytesPerSecond; }
    void setDownloadLimit(int bytesPerSecond);

public slots:
    void transfer();
    void scheduleTransfer();

private:
    QTime stopWatch;
    QSet<NNTPWireClient *> sockets;
    int upLimit;
    int downLimit;
    bool transferScheduled;
};

#endif // RATECONTROLLER_H
